#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h> //sleep


#define BUFFER_SIZE 64
#define RD_SIZE 24

void read_and_sleep(int fd, char* buffer, float seconds){
	int count = read(fd, buffer, RD_SIZE);
	buffer[count] = 0;
	printf("[GOT]: %s\n", buffer);
	sleep(seconds);
}


int main(void){
	int fd;
	int count;
	char buffer[64];

	fd = open("/dev/gps", 0);
	if(fd < 0){
		printf("error open device file.\n");
		exit(1);
	}
	read_and_sleep(fd, buffer, 1.1);
	read_and_sleep(fd, buffer, 0.9);
	read_and_sleep(fd, buffer, 0);

	close(fd);
	return 0;
}

